<template>
  <Card>
    <p slot="title">
      <span>待整改的隐患清单</span>
    </p>
    <ul class="toolbar" slot="extra">
      <li class="item">
        <Input
          v-model="keyword"
          placeholder="输入隐患发生地点以搜索"
          :search="true"
          @on-search="renderTable(0)"
          enter-button="立即搜索"
        ></Input>
      </li>
    </ul>
    <Table :columns="tableColumns" :data="TableData" :height="400"></Table>
    <Divider />
    <Page show-elevator :page-size="PageSize" :total="PageCount" @on-change="renderTable"></Page>
    <Spin fix size="large" v-show="loading.PDTable"></Spin>
  </Card>
</template>

<script>
import axios from "axios";
export default {
  name: "",
  data() {
    return {
      tableColumns: [
        {
          title: "序号",
          key: "index",
          align: "center",
          width: 80
        },
        {
            title:'产生隐患单位',
            key:'dangerDepName',
            align:'center'
        },
        {
          title: "隐患情况",
          key: "dangerContent",
          align: "center"
        },
        {
          title: "所在地址",
          key: "dangerAddress",
          align: "center"
        },
        {
          title: "出现时间",
          key: "questionTime",
          align: "center"
        },
        {
          title: "消防安全责任人",
          key: "questionChargerName",
          align: "center"
        },
        {
          title: "隐患解决情况",
          key: "questionStatus",
          align: "center"
        }
      ],
      keyword: null,
      TableData: [],
      PageSize: 10,
      
      PageCount: 0,
      startTime: this.dateShift(0) + " 00:00:00",
      endTime: this.dateShift(0) + " 23:59:59",
      loading: false
    };
  },
  methods: {
    renderTable(index) {
      this.loading = true;
      let params = {
        MC: this.keyword,
        startTime: this.startTime,
        endTime: this.endTime,
        pageIndex: index,
        pageSize: this.pdPageSize
      };
      axios
        .get(this.URLHEAD_TA + "NewGetWTTZ", { params: params })
        .then(res => {
          let json = res.data;
          this.loading = false;
          this.TableData = json.Data.Data.map((o, i) => {
            return {
              index: i + 1,
              dangerDepName:o.MC,
              dangerContent: `${o.AlarmType}存在${o.QTexts}问题`,
              dangerAddress: o.Address,
              questionTime: o.AlarmTime,
              questionStatus: o.Status || "未反馈处理结果",
              questionChargerName: `${o.FireDuty ||
                "暂无联系人信息"}（${o.FireDutyTel || "暂无联系方式"}）`
            };
          });
          this.PageCount = json.Data.count;
        });
    },
    
  },
  mounted() {
    this.renderTable(0);
  }
};
</script>

<style scoped>
</style>